LinkedIn API Setup Guide
Step 1: Create a LinkedIn App
- Go to LinkedIn Developer Portal
- Click "Create app"
- Fill in the form:
- App name: CMMC Watch Monitor
- LinkedIn Page: Your personal LinkedIn page (or create a company page)
- App logo: Upload any image (512x512px recommended)
- Legal agreement: Check the box
- Click "Create app"
Step 2: Configure Products
- In your app dashboard, go to the "Products" tab
- Request access to:
- β "Sign In with LinkedIn using OpenID Connect" (usually instant approval)
- β "Share on LinkedIn" (usually instant approval)
- β³ "Marketing Developer Platform" (may require review - this gives you access to Organization Posts)
Note: For personal profiles, you may need "Marketing Developer Platform" access, which requires LinkedIn review (can take 1-2 weeks). For company pages, "Share on LinkedIn" may be sufficient.
Step 3: Get Your Credentials
- Go to the "Auth" tab
- Copy these values:
- Client ID:
78xxxxxxxxxxxxx - Client Secret:
xxxxxxxxxxxx - Add Redirect URLs:
- Add:
http://localhost:8888/callback - Add:
https://cmmcwatch.com/callback(if deploying)
Step 4: Add Credentials to .env
# LinkedIn API (Official)
LINKEDIN_CLIENT_ID=your_client_id_here
LINKEDIN_CLIENT_SECRET=your_client_secret_here
LINKEDIN_ACCESS_TOKEN= # Will be generated by oauth script
LINKEDIN_REFRESH_TOKEN= # Will be generated by oauth script
Step 5: Run OAuth Flow
cd scripts
python3 linkedin_oauth.py
This will:
1. Open a browser window for LinkedIn authorization
2. Redirect you to localhost:8888/callback after authorization
3. Automatically extract and save your access token to .env
Step 6: Test the API
python3 linkedin_fetch.py --test
Should output your recent LinkedIn posts.
Step 7: Integrate into Pipeline
Once working, the daily trend collector will automatically use linkedin_fetch.py instead of Apify.
Troubleshooting
"access_denied" Error
- Make sure you've requested the correct Products in Step 2
- Wait for "Marketing Developer Platform" approval if needed
"Invalid redirect_uri"
- Double-check that
http://localhost:8888/callbackis added in the Auth tab
"Expired token"
- LinkedIn tokens expire after 60 days
- Re-run
python3 linkedin_oauth.pyto refresh
Can't Access Profile Posts
- LinkedIn API has limited access to personal profiles
- You may only be able to fetch organization/company page posts
- Alternative: Use RSSHub or continue with Apify for personal profiles
API Limits (Free Tier)
- Rate limit: 500 requests/day
- Typical usage: 4 profiles Γ 3 posts/day = ~50 requests/day
- Cost: FREE
Much better than Apify's $5-50/month! π